package common.utils
{
	public class Time
	{
		public function Time()
		{
		}
		/**
		 * 将秒数转化成标准时间格式的字符串，如00:05:32或0:0:6
		 * @param second 时间，单位：秒
		 * @param spaceStr 分隔符，默认为 ":"
		 * @param isAutoAddZero 对于小于10的数字是否自动补充0以对齐位数
		 * @return 
		 * 
		 */
		public static function transformSecondToString(second:uint,spaceStr:String=":",isAutoAddZero:Boolean = true):String{
			var h:String;
			var m:String;
			var s:String;
			h = int(second/60/60).toString();
			m = int((second/60)-int(h)*60).toString();
			s = int(second%60).toString();
			if(isAutoAddZero == true){
				if(h.length == 1){
					h = "0"+h;
				}
				if(m.length == 1){
					m = "0" + m;
				}
				if(s.length == 1){
					s = "0" + s;
				}
			}
			return h+spaceStr+m+spaceStr+s;
		}
		
		public static function transformSecondToStringXX(second:uint,format:String="hh:mm:ss"):String
		{
			var strtem:String = format;
			var h:String;
			var m:String;
			var s:String;
			
		
			h = int(second/60/60).toString();
			m = int((second/60)-int(h)*60).toString();
			s = int(second%60).toString();
			
			var hh:String = h;
			var mm:String = m;
			var ss:String = s;
			
			if(h.length == 1){
				hh = "0"+h;
			}
			if(m.length == 1){
				mm = "0" + m;
			}
			if(s.length == 1){
				ss = "0" + s;
			}
			strtem = strtem.replace("hh",hh);
			strtem = strtem.replace("mm",mm);
			strtem = strtem.replace("ss",ss);
			strtem = strtem.replace("h",h);
			strtem = strtem.replace("m",m);
			strtem = strtem.replace("s",s);
			return strtem;
		}
	}
}